package com.lizheng.yunservice.travel.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lizheng.yunservice.common.domain.PageQuery;
import com.lizheng.yunservice.common.page.TableDataInfo;
import com.lizheng.yunservice.travel.mapper.VtpVoteWorkImgMapper;
import com.lizheng.yunservice.travel.mapper.VtpVoteWorkMapper;
import com.lizheng.yunservice.travel.doamin.bo.VtpVoteWorkBo;
import com.lizheng.yunservice.travel.doamin.vo.VtpVoteWorkVo;
import com.lizheng.yunservice.travel.service.IVtpVoteWorkService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 投票作品Service业务层处理
 *
 * @author lizheng
 * @date 2024-06-06
 */
@RequiredArgsConstructor
@Service
public class VtpVoteWorkServiceImpl implements IVtpVoteWorkService {

    private final VtpVoteWorkMapper baseMapper;
    private final VtpVoteWorkImgMapper voteWorkImgMapper;


    /**
     * 小程序查询作品列表
     */
    @Override
    public TableDataInfo<VtpVoteWorkVo> queryAppPageList(VtpVoteWorkBo bo, PageQuery pageQuery) {
        Page<VtpVoteWorkVo> result = baseMapper.selectVoPage(pageQuery.build(), bo);
        result.getRecords().forEach(work -> {
            work.setImgs(voteWorkImgMapper.selectListByWorkId(work.getWorkId()));
        });
        return TableDataInfo.build(result);
    }
}
